<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="${bpmTaskFrom.fromName}--${config.getKey('COMPANY_NAME')}" libs=["table"]/>
<link rel="stylesheet" href="${ctxStatic}/static/css/figol.css?V=${config.getDvVersion()}"/>
<div class="oa-form">
    <div class="form-top" style="margin-top:8px;padding-left:20px;">
        <button onclick="saveAsDraft()" type="button" class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-save" style="padding-right:5px;"></i>保存待发
        </button>
        <button disabled class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-plus-square" style="padding-right:5px;"></i>调用模板
        </button>
        <button disabled class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-save" style="padding-right:5px;"></i>存为模板
        </button>
        <button onclick="doPrint()" class="btn btn-info btn-rounded btn-sm">
            <i class="fa fa-print" style="padding-right:5px;"></i>打印
        </button>
    </div>
    <div class="form-bottom">
        <div class="form-bottom-left">
            <@f.form name="biddirectory" class="form-horizontal">
            <div class="form-content">
                <div class="form-title">

                    <table style="width:100%;" class="table table-no-bordered table-form-title">
                        <tr>
                            <td width="10%" rowspan="2" style="text-align:center;border-bottom:0 !important;">
                                <button type="button" onclick="submitHandler()" style="padding:20px 30px;" class="btn btn-danger btn-rounded btn-sm">发 送</button>
                            </td>
                            <td width="6%" style="text-align:right;border-bottom:0 !important;">标题：</td>
                            <td style="border-bottom:0 !important;">
                                <@f.input readonly=true name="title" value="供应商名录备案盖章申请登记表-{创建人}（{创建时间}）" placeholder="供应商名录备案盖章申请登记表-{创建人}（{创建时间}）"  required=true/>
                            </td>
                            <td width="15%" style="border-bottom:0 !important;">
                                <@f.select required=true name="priority" dictType="sys_bpm_priority" blankValue="" blankLabel="请选择紧急程度"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align:right;border-bottom:0 !important;">流程：</td>
                            <td style="border-bottom:0 !important;">
                                <@f.input value="${proDef.name}" readonly=true name="bmp_name" placeholder="审批流程名称"/>
                            </td>
                            <td style="border-bottom:0 !important;">
                                <button type="button" onclick="preview('${bpmTaskFrom.processDefinitionKey}')" style="width:100%;" class="btn btn-info btn-rounded btn-sm">查看流程</button>
                            </td>
                        </tr>
                    </table>

                </div>
                <div id="printBox" class="form-main" style="padding-bottom:60px;background-color:#fff;overflow-x:hidden;overflow-y: auto;">

                    <#include "formToAdd.html"/>

                    <input type="hidden" name="modelKey" value="${bpmTaskFrom.modelKey}" />
                    <input type="hidden" name="formName" value="${bpmTaskFrom.fromName}" />
                    <input type="hidden" name="formId" value="${bpmTaskFrom.id}" />
                </div>
            </div>
            <!--<div class="form-attach">-->
                <!--<div style="width:90%;margin:-1px auto 0;background-color:#ccc;">-->
                    <!--<div class="button-attach" style="height:50px;line-height:50px;font-size:14px;background-color:#ccc;">-->
                        <!--<i style="padding:0 5px 0 10px;" class="icon-attach fa fa-angle-double-down"></i>附言-->
                    <!--</div>-->
                    <!--<div style="width:99%;margin:0 auto;">-->
                        <!--<textarea name="attachment" placeholder="2000字以内" style="border:1px solid #ddd;width:100%;height:70px;"></textarea>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
        </@f.form>
    </div>
    <div class="form-bottom-right" style="background-color: white;">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">相关数据</li>
                <li>流程预测</li>
            </ul>
            <div id="test" class="layui-tab-content">
                <div class="layui-tab-item layui-show">暂无相关数据</div>
                <div class="layui-tab-item">暂无流程预测</div>
            </div>
        </div>
    </div>
</div>
</div>
<@footer>
<!-- jquery.browser方法兼容代码 -->
<script>jQuery.browser={};(function(){jQuery.browser.msie=false;jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)./)){jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1;}})();</script>
<script src="${ctxStatic}/static/js/jquery.jqprint.js"></script>
<script type="text/javascript">
    var prefix = baseURL + "bpm/biddirectory";
    function doPrint(){
        $("#printBox").jqprint();
    }
    $('form[name=biddirectory]').validate({
        rules:{
            project_name:{
                required:true,
                minlength: 1,
                maxlength: 200
            },
        },
        focusCleanup: true
    });

    function saveAsDraft() {
        if (opt.validate.form()) {
            console.log(prefix)
            console.log($('form[name=biddirectory]').serialize());
            opt.operate.save(prefix + "/saveAsDraft", $('form[name=biddirectory]').serialize(), function (data) {
                console.log(data);
                if(data.code==="00000"){
                    opt.success("操作成功");
                    setTimeout(function (){closeWindow();}, 2000);
                }else{
                    opt.error(data.msg);
                }
            });
        }
    }

    function submitHandler() {
        if (opt.validate.form()) {
            console.log(prefix)
            console.log($('form[name=biddirectory]').serialize());
            opt.operate.save(prefix + "/add", $('form[name=biddirectory]').serialize(), function (data) {
                console.log(data);
                if(data.code==="00000"){
                    opt.success("操作成功");
                    setTimeout(function (){closeWindow();}, 2000);
                }else{
                    opt.error(data.msg);
                }
            });
        }
    }

    function closeWindow() {
        if (navigator.userAgent.indexOf('MSIE') > 0) { // close IE
            if (navigator.userAgent.indexOf('MSIE 6.0') > 0) {
                window.opener = null;
                window.close();
            } else {
                window.open('', '_top');
                window.top.close();
            }
        } else { // close chrome;It is effective when it is only one.
            window.opener = null;
            window.open('', '_self');
            window.close();
        }
    }

    /*预览*/
    function preview(id) {
        var options = {
            url: baseURL + "bpm/procdef/preview/" + id,
            title: '<i class="fa icon-loop"></i> <@ctx.i18n text = "流程跟踪"/>',
            btn:['<i class="fa fa-close"></i> '+$.i18n.prop("取消")],
            width: $(top.window).width() - 300,
            height: $(top.window).height() - 200
        };
        opt.modal.openMainWin(options);
    }

    /*$("button[name=btn-save]").click(function () {
        console.log("aaaaaaaaaaaa")
        if (opt.validate.form()) {
            console.log("bbbbbbbbbbbbbbbbb")
            opt.operate.post(prefix + "/add", $('form[name=biddirectory]').serialize());
        }
    });*/

    $(".button-attach").click(function () {
        $(".form-attach").toggleClass("expand");
        $(".icon-attach").toggleClass("fa-angle-double-up").toggleClass("fa-angle-double-down");
    });
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>
</@footer>
</@pageTheme>